package com.mftour.moudles.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mftour.moudles.entity.RolePermission;
import com.mftour.moudles.mapper.RolePermissionMapper;
import com.mftour.moudles.service.RolePermissionService;

@Service
public class RolePermissionServiceImpl extends BaseServiceImpl<RolePermission,Integer> implements RolePermissionService {
	@Autowired
	RolePermissionMapper rolePermissionMapper;

	
	@Override
	public boolean updateRolePermissions(String permissionIds, Integer roleId) {
		boolean result = false;
		RolePermission rp = new RolePermission();
		rp.setRoleId(roleId);
		deleteSelective(rp);
		if (permissionIds != null) {
			for (String permissionId : permissionIds.split(",")) {
				RolePermission rolePermission = new RolePermission();
				rolePermission.setPermissionId(Integer.parseInt(permissionId));
				rolePermission.setRoleId(roleId);
				insertSelective(rolePermission);
			}
		}
		result = true;
		return result;
	}
}